const path = require('path');
const { lineShutdown } = require('./shutdowns.js');
const { readJsonFileSync } = require('./util/file.js');
const { init:watcherInit } = require('./watcher/watcher.js');
const { start:dbStart } = require('./database.js');
// const { isEmpty, removeDuplicates, removeEmpty, removeDuplicatesAndEmpty } = require('./util/common.js');
// const { parseM3u8File } = require('./util/m3u8.js');

// 获取除了Node可执行文件和脚本名之外的参数
const args = process.argv.slice(2);
// 输出参数
args.forEach((arg, index) => {
  console.log(`Argument ${index + 1}:`, arg);
});

let defaultConf = readJsonFileSync("default.json");
let customConf = readJsonFileSync("custom.json", false, {});
const conf = Object.assign({}, defaultConf, customConf);

console.info("defaultConf: " + JSON.stringify(defaultConf));
console.info("customConf: " + JSON.stringify(customConf));

console.info("config: " + JSON.stringify(conf));

const watcher = watcherInit(conf);
// const pool = dbStart(conf);

lineShutdown();